
-- Workspace KRT ------------------------------

workspace "KRayTracing"
	architecture "x64"

	startproject "Offline"
	
	configurations {
		"Debug",
		"Release"
	}

	flags {
		"MultiProcessorCompile"
	}

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
dynamicdef = "KRT_DYNAMIC_LIB"
staticdef = "KRT_STATIC_LIB"

-- include direction
IncludeDir = {}
IncludeDir["stb"] = "KRayTracing/vendor/stb"
IncludeDir["glm"] = "KRayTracing/vendor/glm"

-- include outher premake config
include "KRayTracing/vendor/stb"

-- KRayTracing ----------------------------------------

project "KRayTracing"
	location "KRayTracing"
	kind "SharedLib"
	language "C++"
	cppdialect "C++17"
	-- staticruntime "on"

	targetdir ("bin/" .. outputdir .. "/%{prj.name}")
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	pchheader "krtpch.h"
	pchsource "KRayTracing/src/krtpch.cpp"

	files {
		"%{prj.name}/include/**.h",
		"%{prj.name}/src/**.cpp",

		"%{prj.name}/vendor/glm/glm/**.hpp",
		"%{prj.name}/vendor/glm/glm/**.inl",
	}

	defines {
		"_CRT_SECURE_NO_WARNINGS",
	}

	includedirs {
		"%{prj.name}/include",
		"%{IncludeDir.glm}",
		"%{IncludeDir.stb}",
	}

	links {
		"stb",
	}

	filter "system:windows"
		systemversion "latest"

		defines {
			dynamicdef,
			"KRT_BUILD_DLL",
			"KRT_PLATFORM_WINDOWS",

			"STB_IMAGE_IMPLEMENTATION",
			"STB_IMAGE_WRITE_IMPLEMENTATION",
		}
		
		postbuildcommands {
			"{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/Offline"
		}

	filter "configurations:Debug"
		defines "KRT_DEBUG"
		runtime "Debug"
		symbols "On"

	filter "configurations:Release"
		defines "KRT_RELEASE"
		runtime "Release"
		optimize "On"


-- Offline --------------------------------------

project "Offline"
	location "Offline"
	kind "ConsoleApp"
	language "C++"
	cppdialect "C++17"
	-- staticruntime "on"
	
	targetdir ("bin/" .. outputdir .. "/%{prj.name}")
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	files {
		"%{prj.name}/include/**.h",
		"%{prj.name}/src/**.cpp"
	}

	includedirs {
		"KRayTracing/include",
		"%{IncludeDir.glm}",
		"%{IncludeDir.stb}",
	}

	links {
		"KRayTracing",
		"stb",
	}

	filter "system:windows"
		systemversion "latest"

		defines {
			"_CRT_SECURE_NO_WARNINGS",

			dynamicdef,
			"KRT_PLATFORM_WINDOWS",
			"STB_IMAGE_IMPLEMENTATION",
			"STB_IMAGE_WRITE_IMPLEMENTATION",
		}

	filter "configurations:Debug"
		defines "KRT_DEBUG"
		runtime "Debug"
		symbols "On"

	filter "configurations:Release"
		defines "KRT_RELEASE"
		runtime "Release"
		optimize "On"

